package com.moorror.codegenvel.utils;

import java.lang.reflect.Field;

/**
 * @Author jiyanghuang
 * @Date 2024/6/16 19:26
 */
public class AnnotationUtils {

    public static String FEIGN_CLIENT = "org.springframework.cloud.openfeign.FeignClient";

    /**
     * 形如：com.moorror.java.base.summary.guava.velocity.bean.FieldDesc#query
     *
     * @param key
     * @return
     */
    public static String[] annArray(String key) {
        try {
            String[] classFields = key.split("#");
            if (2 == classFields.length) {
                Class<?> clazz = Class.forName(classFields[0]);
                Field field = clazz.getDeclaredField(classFields[1]);
                field.setAccessible(true);
                return (String[]) field.get(null);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return new String[]{};
    }
}
